#include <fstream>
#include "rungekutta2.h"
#include "../rungekutta2_serial/rungekutta2.h"
#include "../rungekutta2_serial/Timer.h"

using namespace std;
Stopwatch *s;
int main(int argc, char **argv)
{
	float *pA, h, *y0, *res;
	ofstream out("log.txt");
	s = createStopwatch();
	for (size_t n = 2, steps = n * 128; n <= 1<<6; n*=2, steps = n * 128)
	{
		s->reset();
		
		pA = new float[n * n];
		y0 = new float[n];
		res = new float[n * steps];
		RandomInitData(pA, h, y0, n);
		copy(y0, y0 + n, res);
		//alg begin
		//s->start();
		cuda_midpointMethod(pA, n, h, steps-1, res);
		//s->stop();
		//alg end
		out << "{" << n << "," << s->getElapsed() << "},";
		if (!IsCorrectResult(pA, n, h, y0, res, steps))
			printf("error n=%d", n);
		delete[] pA;
		delete[] y0;
		delete[] res;
	}

	return 0;
}
